package com.aiyige.page.selectinterest.adapter;

import android.view.View;
import android.widget.ImageView;
import android.widget.TextView;

import com.aiyige.R;
import com.aiyige.page.selectinterest.model.StateItem;
import com.chad.library.adapter.base.BaseQuickAdapter;
import com.chad.library.adapter.base.BaseViewHolder;

import java.util.LinkedList;

import butterknife.BindView;
import butterknife.ButterKnife;

/**
 * Created by zhuyakun on 2017/10/25.
 */

public class StateAdapter extends BaseQuickAdapter<StateItem, StateAdapter.StatePageViewHolder> {


    public StateAdapter() {
        super(R.layout.state_item, new LinkedList<StateItem>());
    }

    @Override
    protected void convert(StatePageViewHolder helper, StateItem item) {
        helper.bindData(item);
    }

    public static class StatePageViewHolder extends BaseViewHolder {
        @BindView(R.id.titleTv)
        TextView titleTv;
        @BindView(R.id.icon)
        ImageView icon;

        public StatePageViewHolder(View view) {
            super(view);
            ButterKnife.bind(this, view);
        }

        public void bindData(StateItem item) {
            if (item.getType() == StateItem.TYPE_CLEAN) {
                titleTv.setText(R.string.clean_all);
                icon.setImageResource(R.drawable.interest_delete);
            } else {
                titleTv.setText(item.getTitle());
                icon.setImageResource(R.drawable.interest_delete1);
            }
        }
    }
}
